//
//  JDDTabBarViewController.m
//  JDD
//
//  Created by 张露杰 on 17/10/23.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "RWBTabBarViewController.h"
#import "HWDNavigationController.h"

#import "UrbanMainViewController.h"
#import "UrbanAdvisoryViewController.h"
#import "UrbanMyViewController.h"

#define tabBarHeight 49

@interface RWBTabBarViewController ()<UIAlertViewDelegate>

@property (nonatomic, strong) NSArray *nameArray;

@property (nonatomic, strong) NSArray *imageName;

@property (nonatomic, strong) NSArray *titleArr;

@end

@implementation RWBTabBarViewController

#pragma mark - 第一次使用当前类的时候对设置UITabBarItem的主题


- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpAllChildVc];
}

#pragma mark - ------------------------------------------------------------------
#pragma mark - 初始化tabBar上除了中间按钮之外所有的按钮

- (void)setUpAllChildVc
{
    UrbanMainViewController *HomeVC = [[UrbanMainViewController alloc] init];
    [self setUpOneChildVcWithVc:HomeVC Image:@"home" selectedImage:@"home_s" title:@"首页"];

    UrbanAdvisoryViewController *advisoryVC = [[UrbanAdvisoryViewController alloc] init];
    [self setUpOneChildVcWithVc:advisoryVC Image:@"news" selectedImage:@"new_s" title:@"咨询"];
    
    UrbanMyViewController *myVC = [[UrbanMyViewController alloc] init];
    [self setUpOneChildVcWithVc:myVC Image:@"my" selectedImage:@"my_s" title:@"个人中心"];
}

#pragma mark - 初始化设置tabBar上面单个按钮的方法

/**
 *  @author li bo, 16/05/10
 *
 *  设置单个tabBarButton
 *
 *  @param Vc            每一个按钮对应的控制器
 *  @param image         每一个按钮对应的普通状态下图片
 *  @param selectedImage 每一个按钮对应的选中状态下的图片
 *  @param title         每一个按钮对应的标题
 */
- (void)setUpOneChildVcWithVc:(UIViewController *)Vc Image:(NSString *)image selectedImage:(NSString *)selectedImage title:(NSString *)title
{
    HWDNavigationController *nav = [[HWDNavigationController alloc] initWithRootViewController:Vc];
    UIImage *myImage = [UIImage imageNamed:image];
    myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //tabBarItem，是系统提供模型，专门负责tabbar上按钮的文字以及图片展示
    Vc.tabBarItem.image = myImage;
    UIImage *mySelectedImage = [UIImage imageNamed:selectedImage];
    mySelectedImage = [mySelectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    Vc.tabBarItem.selectedImage = mySelectedImage;
    Vc.tabBarItem.title = title;
    [self addChildViewController:nav];
}


- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    return YES;
}

@end
